package javaDemo04.Poker;

import java.util.ArrayList;
import java.util.Collections;

public class Main {
    public static void add(ArrayList<String> arr) {
        String[] str = {"♣", "♠", "♦", "♥"};
        String[] str1 = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2",};
        for (String s : str) {
            for (String value : str1) {
                arr.add(s + value);
            }
        }
        arr.add("小王");
        arr.add("大王");
    }


    public static void fapai(ArrayList<String> arr, ArrayList<String> one, ArrayList<String> two, ArrayList<String> three) {
        int l = (arr.size() - 3) / 3;
        int r = (arr.size() - 3) / 3 * 2;
        ArrayList<String> dp = new ArrayList<String>();

        for (int a = 0; a < l; a++) {
            one.add(arr.get(a));
        }
        for (int b = l;b < r; b++) {
            two.add(arr.get(b));
        }
        for (int c = r; c < arr.size() - 3; c++) {
            three.add(arr.get(c));
        }
        for(int d = arr.size() - 3;d < arr.size();d++){
            dp.add(arr.get(d));
        }
        System.out.println("底牌为" + dp.toString());

    }

    public static void show(String name,ArrayList<String> arr){
        System.out.println(name + "的牌为：");
        System.out.println(arr.toString());
    }
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<String>();
        ArrayList<String> one = new ArrayList<String>();
        ArrayList<String> two = new ArrayList<String>();
        ArrayList<String> three = new ArrayList<String>();

        add(list);//添加牌库
        Collections.shuffle(list);//洗牌
        fapai(list,one,two,three);//发牌
        show("玩家一",one);
        show("玩家二",two);
        show("玩家三",three);




    }
}


